package org.example.game.biweekly.game136;

/**
 * @Description: TODO
 * @Author wyatt
 * @Data 2024/08/03 20:46
 */
public class Solution002 {

    public static void main(String[] args) {
        System.out.println(new Solution002().minFlips(new int[][]{{0,1},{0,1},{0,0}}));
    }


    public int minFlips(int[][] grid) {

        //翻转的本质，是找出不回文，不相等的数量
        int m = 0;
        int n = 0;

        for (int i = 0; i < grid.length; i++) {
            int[] line = grid[i];
            int start = 0;
            int end = line.length-1;
            while (start < end) {
                if(line[start] != line[end]){
                    m++;
                }
                start++;
                end--;
            }
        }

        for (int j = 0; j < grid[0].length; j++) {
            int start = 0;
            int end = grid.length-1;
            while (start < end) {
                if(grid[start][j] != grid[end][j]){
                    n++;
                }
                start++;
                end--;
            }
        }

        return Math.min(m, n);
    }
}
